package me.helllp.book.netty.step00;

import java.net.ServerSocket;
import java.net.Socket;

public class TimeServer {
	public void start() throws Exception{
		ServerSocket server = null;
		
		try {
			server = new ServerSocket(7000);
			
			Socket socket = null;
			
			//	创建线程池
			TimeServerHandlerExecutorPool pool = new TimeServerHandlerExecutorPool(10, 20);
			
			while(true){
				socket = server.accept();
				pool.executor(new TimeServerHandler(socket));
//				new Thread(new TimeServerHandler(socket)).start();
			}
		} finally {
			if(server != null){
				server.close();
			}
		}
	}
	
	public static void main(String[] args) throws Exception {
		TimeServer server = new TimeServer();
		server.start();
	}
}
